CC      = gcc
CCFLAGS = -O2 -s -fPIC
LDFLAGS=-lglib-2.0 -lcups
SUBDIRS= sys printer tcp_client mp4_player gtk_gui keeper
#SUBDIRS= sys printer tcp_client gtk_gui keeper

RECURSIVE_MAKE= @for subdir in $(SUBDIRS);\
        do\
        echo "making in $$subdir";\
        ( cd $$subdir && $(MAKE) -f Makefile -e CC='${CC}' CCFLAGS='${CCFLAGS}' LDFLAGS='${LDFLAGS}') || exit 1;\
        done

RECURSIVE_CLEAN= @for subdir in $(SUBDIRS);\
        do\
        echo "cleaning in $$subdir";\
        ( cd $$subdir && $(MAKE) clean) || exit 1;\
        done

subdirs:
	$(RECURSIVE_MAKE)

all: subdirs
	chmod 777 -R bin
	sudo cp bin/*.so /usr/lib
#	sudo chmod 440 ./bin/res/sudoers

.PHONY: all subdirs install clean

install:
#	sudo rm  ./bin/ad/*
	sudo chmod -R 777 ./bin
	tar -zczf webprint.tar.gz bin
	sudo chmod 777 webprint.tar.gz

clean:
	$(RECURSIVE_CLEAN)

